#include "Reactor.hpp"
#include "Listener.hpp"

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cout << "Usage: " << argv[0] << " port" << std::endl;
        return 1;
    }
    ENABLE_CONSOLE_LOG();

    uint16_t local_port = std::stoi(argv[1]);
    auto conn = std::make_shared<Listener>(local_port);

    // // 模块一
    // Listener listen(local_port);

    // // 模块二
    // auto conn = Factory::BuildConnection(listen.Sockfd(), EPOLLIN | EPOLLET, 
    //                         [&listen](){ listen.Accepter(); }, nullptr, nullptr);

    // 模块三
    Reactor reactor;
    reactor.InsertConnection(conn);
    reactor.Loop();
    return 0;
}